import java.util.Arrays;

public class ArrayExercise {
    public static void main(String[] args) {
        int[] numbers = {3, 7, 2, 9, 1, 8, 5};
        
        // 1. 最大值和最小值
        int max = numbers[0], min = numbers[0];
        for (int num : numbers) {
            if (num > max) max = num;
            if (num < min) min = num;
        }
        System.out.println("最大值: " + max + ", 最小值: " + min);
        
        // 2. 数组反转
        int[] reversed = new int[numbers.length];
        for (int i = 0; i < numbers.length; i++) {
            reversed[i] = numbers[numbers.length - 1 - i];
        }
        System.out.println("反转后: " + Arrays.toString(reversed));
        
        // 3. 检查元素
        int target = 9;
        boolean contains = false;
        for (int num : numbers) {
            if (num == target) {
                contains = true;
                break;
            }
        }
        System.out.println("数组是否包含" + target + ": " + contains);
        
        // 4. 计算平均值
        double sum = 0;
        for (int num : numbers) {
            sum += num;
        }
        System.out.println("平均值: " + (sum / numbers.length));
    }
}
